package lumis.portal.sendmail;

import lumis.portal.stability.StableMinor;

/**
 * Stores the configuration for the sendmail component.
 * 
 * @version $Revision: 13082 $ $Date: 2011-05-27 16:03:12 -0300 (Fri, 27 May 2011) $
 * @since 4.0.4
 */
@StableMinor(version = "6.0", sinceVersion = "4.0")
public interface IMailConfig
{	
	/**
	 * Possible cryptographic protocols used in mail.
	 * 
	 * @see IMailConfig#getCryptographicProtocol()
	 * @see IMailConfig#setCryptographicProtocol(CryptographicProtocol)
	 *
	 * @version $Revision: 13082 $ $Date: 2011-05-27 16:03:12 -0300 (Fri, 27 May 2011) $
	 * @since 5.6.0
	 */
	@StableMinor(version = "6.0", sinceVersion = "5.6")
	public static enum CryptographicProtocol
	{
		/**
		 * No cryptographic protocol being used.
		 * @since 5.6.0
		 */
		NONE,
		/**
		 * Using SSL protocol.
		 * @since 5.6.0
		 */
		SSL,
		/**
		 * Using TLS protocol.
		 * @since 5.6.0
		 */
		TLS;
	}
	
	/**
	 * Returns the time in seconds for mail queue lock timeout.
	 * The queue is locked for processing, and this timeout is necessary
	 * to unlock the queue if its processing thread has died.
	 * @return the time in seconds for mail queue lock timeout.
	 * @since 4.0.4
	 */
	public int getQueueLockTimeout();

	/**
	 * Sets the time in seconds for mail queue lock timeout.
	 * @param queueLockTimeout the value to set.
	 * @see #getQueueLockTimeout()
	 * @since 4.0.4
	 */
	public void setQueueLockTimeout(int queueLockTimeout);
	
	/**
	 * Returns true if mails sent successfully should be automatically 
	 * removed from the database.
	 * @return true if the mails sent should be removed, false otherwise.
	 * @since 4.0.4
	 */
	public boolean getRemoveMailsSent();

	/**
	 * Sets if mails sent successfully should be automatically
	 * removed from the database.
	 * @param remove the value to set.
	 * @since 4.0.4
	 */
	public void setRemoveMailsSent(boolean remove);
	
	/**
	 * Returns the interval, in seconds, to wait when a block
	 * of {@link #getBlockSize()} mails are sent.
	 * @return the interval set.
	 * @since 4.0.4
	 */
	public int getBlockInterval();

	/**
	 * Sets the interval, in seconds, to wait when a block
	 * of {@link #getBlockSize()} mails are sent. 
	 * @param blockInterval the interval value to set.
	 * @since 4.0.4
	 */
	public void setBlockInterval(int blockInterval);

	/**
	 * Returns the block size. The block size is the number
	 * of mails sent that represents a block.
	 * @return the block size.
	 * @since 4.0.4
	 */
	public int getBlockSize();

	/**
	 * Sets the block size.
	 * @param blockSize the block size value.
	 * @see #getBlockSize()
	 * @since 4.0.4
	 */
	public void setBlockSize(int blockSize);

	/**
	 * Returns the default from e-mail address, that will be used if no from
	 * is specified for a e-mail to be sent. If this default address is also
	 * not set, no from address will be set in the e-mail header. 
	 * @return the default from e-mail address.
	 * @since 4.0.8
	 */
	public String getDefaultFromAddress();

	/**
	 * Sets the default from address.
	 * @param defaultFromAddress the default from address.
	 * @see #getDefaultFromAddress()
	 * @since 4.0.8
	 */
	public void setDefaultFromAddress(String defaultFromAddress);

	/**
	 * Returns the maximum number of threads to process the sendmail queue.
	 * @return the maximum number of threads to process the sendmail queue.
	 * @since 4.0.4
	 */
	public int getMaxSendThreads();

	/**
	 * Sets the maximum number of threads to process the sendmail queue.
	 * @param maxSendThreads the value to set.
	 * @since 4.0.4
	 */
	public abstract void setMaxSendThreads(int maxSendThreads);

	/**
	 * Returns the interval, in seconds, to wait between each mail send in
	 * a thread processing the sendmail queue.
	 * @return the interval, in seconds.
	 * @since 4.0.4
	 */
	public int getSendInterval();

	/**
	 * Sets the interval, in seconds, to wait between each mail send in
	 * a thread processing the sendmail queue.
	 * @param sendInterval the interval, in seconds.
	 * @since 4.0.4
	 */
	public void setSendInterval(int sendInterval);

	/**
	 * Returns the smtp server hostname.
	 * @return the smtp server hostname.
	 * @since 4.0.4
	 */
	public String getSmtpHost();

	/**
	 * Sets the smtp server hostname.
	 * @param smtpHost the value to set.
	 * @since 4.0.4
	 */
	public void setSmtpHost(String smtpHost);

	/**
	 * Returns the smtp server authentication password.
	 * @return the smtp server authentication password.
	 * @since 4.0.4
	 */
	public String getSmtpPassword();

	/**
	 * Sets the smtp server authentication password.
	 * @param smtpPassword the password value.
	 * @since 4.0.4
	 */
	public void setSmtpPassword(String smtpPassword);

	/**
	 * Returns the smtp server connection port.
	 * @return the smtp server connection port.
	 * @since 4.0.4
	 */
	public int getSmtpPort();

	/**
	 * Sets the smtp server connection port.
	 * @param smtpHost the value to set.
	 * @since 4.0.4
	 */
	public void setSmtpPort(int smtpPort);
	
	/**
	 * Returns the cryptographic protocol to be used.
	 * @return	SSL or TLS
	 * @since 5.6.0
	 */
	public CryptographicProtocol getCryptographicProtocol();
	
	/**
	 * Sets the cryptographic protocol to be used.
	 * @param protocol	the string representing the protocol to be used (NONE, SSL or TLS).
	 * @since 5.6.0
	 */
	public void setCryptographicProtocol(CryptographicProtocol protocol);

	/**
	 * Returns the socket connection timeout value in milliseconds.
	 * 0 (zero) meaning infinite timeout.
	 * 
	 * @return the socket connection timeout value in milliseconds.
	 * @since 5.6.0
	 */
	public int getSocketConnectionTimeout();

	/**
	 * Sets the Socket connection timeout value in milliseconds.
	 * Use 0 (zero) to infinite timeout.
	 * 
	 * @param smtpConnectionTimeout the value to set.
	 * @since 5.6.0
	 */
	public void setSocketConnectionTimeout(int socketConnectionTimeout);

	
	/**
	 * Returns the socket I/O timeout value in milliseconds.
	 * @return the socket I/O timeout value in milliseconds.
	 * @since 5.6.0
	 */
	public int getSocketTimeout();

	/**
	 * Sets the socket I/O timeout value in milliseconds.
	 * @param smtpTimeout the value to set.
	 * @since 5.6.0
	 */
	public void setSocketTimeout(int socketTimeout);

	
	/**
	 * Returns the smtp server authentication user.
	 * @return the smtp server authentication user.
	 * @since 4.0.4
	 */
	public String getSmtpUser();

	/**
	 * Sets the smtp server authentication user.
	 * @param smtpUser the smtp server authentication user,
	 * or null if no authentication is to be used. 
	 * @since 4.0.4
	 */
	public void setSmtpUser(String smtpUser);
	
	/**
	 * Returns the class that should be used for sending mails.
	 * It must implement {@link IMailSender}.
	 * @return the class to be used for sending mails.
	 * @since 4.0.4
	 */
	public String getMailSenderClass();

	/**
	 * Sets the class that should be used for sending mails.
	 * It must implement {@link IMailSender}.
	 * @param className the class name to set.
	 * @since 4.0.4
	 */
	public void setMailSenderClass(String className);

}